Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/test(osmomath): change package of decimal_test.go to osmomath_test #3710

Merged
merged 2 commits into from
Dec 14, 2022

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Dec 14, 2022

Progress towards: #3540

What is the purpose of the change

As per title, this is needed to prevent import cycles in tests.

The import cycle I encountered is with osmoutils to import ErrTolerance.

@p0mvn p0mvn added A:backport/v13.x backport patches to v13.x branch V:state/compatible/backport State machine compatible PR, should be backported labels Dec 14, 2022
@p0mvn p0mvn requested a review from stackman27 December 14, 2022 05:43
@p0mvn p0mvn marked this pull request as ready for review December 14, 2022 05:47
Comment on lines 477 to 496
func (s *decimalTestSuite) TestPower() {
testCases := []struct {
input BigDec
power uint64
expected BigDec
}{
{OneDec(), 10, OneDec()}, // 1.0 ^ (10) => 1.0
{NewDecWithPrec(5, 1), 2, NewDecWithPrec(25, 2)}, // 0.5 ^ 2 => 0.25
{NewDecWithPrec(2, 1), 2, NewDecWithPrec(4, 2)}, // 0.2 ^ 2 => 0.04
{NewDecFromInt(NewInt(3)), 3, NewDecFromInt(NewInt(27))}, // 3 ^ 3 => 27
{NewDecFromInt(NewInt(-3)), 4, NewDecFromInt(NewInt(81))}, // -3 ^ 4 = 81
{MustNewDecFromStr("1.414213562373095048801688724209698079"), 2, NewDecFromInt(NewInt(2))}, // 1.414213562373095048801688724209698079 ^ 2 = 2
}

for i, tc := range testCases {
res := tc.input.Power(tc.power)
s.Require().True(tc.expected.Sub(res).Abs().LTE(SmallestDec()), "unexpected result for test case %d, input: %v", i, tc.input)
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been a bit removed from these osmomath changes, just wanted to check if Power is getting tested elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to submit this removal in: #3712

Got a merge conflict here. Thanks for catching

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR lgtm once this is added back!

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though I don't quite understand why it was needed

@p0mvn
Copy link
Member Author

p0mvn commented Dec 14, 2022

LGTM, though I don't quite understand why it was needed

osmoutils imports osmomath. As result, there is an import cycle, preventing ErrTolerance import in tests

@ValarDragon ValarDragon merged commit 7da459f into main Dec 14, 2022
@ValarDragon ValarDragon deleted the roman/dec-package branch December 14, 2022 17:11
mergify bot pushed a commit that referenced this pull request Dec 14, 2022
…h_test (#3710)

* refactor/test(osmomath): change package of decimal_test.go to osmomath_test

* restore power test

(cherry picked from commit 7da459f)
ValarDragon pushed a commit that referenced this pull request Dec 14, 2022
…h_test (#3710) (#3721)

* refactor/test(osmomath): change package of decimal_test.go to osmomath_test

* restore power test

(cherry picked from commit 7da459f)

Co-authored-by: Roman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v13.x backport patches to v13.x branch F: geometric-twap V:state/compatible/backport State machine compatible PR, should be backported
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants